package day16.FanSe.FS03;

import java.lang.reflect.Field;

public class Text {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException {
//        method1();返回所有公共成员变量对象的数组
//        method2();返回所有成员变量对象的数组
//        method3();
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        Field field = aClass.getDeclaredField("money");
        System.out.println(field);
    }

    private static void method3() throws ClassNotFoundException, NoSuchFieldException {
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        Field field = aClass.getField("name");
        System.out.println(field);
    }

    private static void method2() throws ClassNotFoundException {
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
        //        返回所有成员变量对象的数组
        Field[] fields = aClass.getDeclaredFields();
        for (Field field : fields) {
            System.out.println(field);
        }
    }

    private static void method1() throws ClassNotFoundException {
        Class<?> aClass = Class.forName("day16.FanSe.FS03.Student");
//        返回所有公共成员变量对象的数组
        Field[] fields = aClass.getFields();
        for (Field field : fields) {
            System.out.println(field);
        }
    }
}
